﻿<script type="text/javascript">
    $(function () {
        getButton("hzMonthByZhengYear");
    });

    function ui_hzMonthByZhengYear_init_list(toolbar) {
        $("#ui_hzMonthByZhengYear_dg").datagrid({       //初始化datagrid
            url: "ashx/bg_hzMonthByZhengYear.ashx?action=getall",
            striped: true, rownumbers: true,
            singleSelect: true,
            idField: 'pcode',
            sortName: 'pcode',
            sortOrder: 'asc',
            columns: [[

                { field: 'pname', title: '骨灰堂名称', width: 120 },
                { field: 'm1', title: '01月', width: 60 },
                { field: 'm2', title: '02月', width: 60 },
                { field: 'm3', title: '03月', width: 60 },
                { field: 'm4', title: '04月', width: 60 },
                { field: 'm5', title: '05月', width: 60 },
                { field: 'm6', title: '06月', width: 60 },
                { field: 'm7', title: '07月', width: 60 },
                { field: 'm8', title: '08月', width: 60 },
                { field: 'm9', title: '09月', width: 60 },
                { field: 'm10', title: '10月', width: 60 },
                { field: 'm11', title: '11月', width: 60 },
                { field: 'm12', title: '12月', width: 60 },
                { field: 'mm', title: '全年', width: 60 }

            ]],
            footer: "#ui_hzMonthByZhengYear_dg_ft",
            rowStyler: function (index, row) {
                if (row.pname == '合计') {
                    return 'background-color:#6293BB;color:#fff;font-weight:bold;';
                }
            },
            //toolbar: toolbar.length == 0 ? null : toolbar
            //toolbar: [{
            //    text: '导出',
            //    iconCls: 'icon-bug_go',
            //    handler: function () { ui_hzMonthByZhengYear_export(); }
            //}, {
            //    text: '删除',
            //    iconCls: 'icon-bug_delete',
            //    handler: function () { ui_hzMonthByZhengYear_delete(); }
            //}, {
            //    text: '回复',
            //    iconCls: 'icon-bug_edit',
            //    handler: function () { ui_hzMonthByZhengYear_edit(); }
            //}]           
        });
        //回车搜索
        $("#ui_hzMonthByZhengYear_search").find('input').on('keyup', function (event) {
            if (event.keyCode == '13') {
                ui_hzMonthByZhengYear_searchdata();
            }
        });
        var year = new Date().getFullYear();
        $('#ui_hzMonthByZhengYear_search').numberspinner('setValue', year);
        var url = "ashx/bg_hzMonthByZhengYear.ashx?action=export&year=";
        $('#ui_hzMonthByZhengYear_btn_export').attr("url", url + year);
        $('#ui_hzMonthByZhengYear_spanYear').text(year + '年度全市');
    }

    function ui_hzMonthByZhengYear_search() {
        var cityname = $('#ui_hzMonthByZhengYear_areacode').combotree('getText');
        var zheng = "全市";
        if (cityname.length > 0) {
            zheng = "【" + cityname + "】";
        }
        var year = $('#ui_hzMonthByZhengYear_search').numberspinner('getValue');
        $('#ui_hzMonthByZhengYear_spanYear').text(year + '年度' + zheng);
        var type = $('#ui_hzMonthByZhengYear_type').combobox('getValue');
        var areacode = $('#ui_hzMonthByZhengYear_areacode').combotree('getValue');
        var url = "ashx/bg_hzMonthByZhengYear.ashx?action=export&year=" + year + "&type=" + type+"&areacode="+areacode;
        $('#ui_hzMonthByZhengYear_btn_export').attr("url", url);
        $('#ui_hzMonthByZhengYear_dg').datagrid("load", { year: year, type: type, areacode: areacode });
    }

    function ui_hzMonthByZhengYear_export() {
        var url = $('#ui_hzMonthByZhengYear_btn_export').attr("url");
        if (!url) {
            $.show_warning("提示", "请先查询结果，然后再导出");
        }
        var t = new Date().getTime();
        url = url + "&t=" + t;
        $('#ui_hzMonthByZhengYear_export_excel').attr('src', url);
    }
    function ui_hzMonthByZhengYear_export2() {
        var url = $('#ui_hzMonthByZhengYear_btn_export2').attr("url");
        if (url) {
            var t = new Date().getTime();
            url = url + "&t=" + t;
            $('#ui_hzMonthByZhengYear_export_excel').attr('src', url);
        }
    }

    function ui_hzMonthByZhengYear_detail() {
        var year = $('#ui_hzMonthByZhengYear_search').numberspinner('getValue');
        var rows = $("#ui_hzMonthByZhengYear_dg").datagrid("getChecked");
        if (rows.length != 1) {
            $.show_warning("提示", "请先选择要一行数据");
            return;
        }
        var row = rows[0];
        var $ui_hzMonthByZhengYear_layout = $("#ui_hzMonthByZhengYear_layout");
        var hzMonthByZhengYear = $ui_hzMonthByZhengYear_layout.layout("panel", "east");

        if (hzMonthByZhengYear.panel("options").collapsed) {   //判断是否展开
            $ui_hzMonthByZhengYear_layout.layout("expand", "east");
        }

        var url = "ashx/bg_hzMonthByZhengYear.ashx?action=export&op=hzsection&paradisecode=" + row.pcode + "&year=" + year;
        $('#ui_hzMonthByZhengYear_btn_export2').attr("url", url);

        hzMonthByZhengYear.panel("setTitle", "【" + row.pname + "】入葬统计");
        if ($("#ui_hzMonthByZhengYear_dg2").data("datagrid")) {
            $("#ui_hzMonthByZhengYear_dg2").datagrid({       //请求数据
                url: "ashx/bg_hzMonthByZhengYear.ashx?action=getall&op=hzsection&paradisecode=" + row.pcode + "&year=" + year
            });
        }
        else {
            $("#ui_hzMonthByZhengYear_dg2").datagrid({       //初始化datagrid
                url: "ashx/bg_hzMonthByZhengYear.ashx?action=getall&op=hzsection&paradisecode=" + row.pcode + "&year=" + year,
                striped: true, rownumbers: true,
                singleSelect: true,
                idField: 'pname',
                columns: [[

                    { field: 'pname', title: '区名', width: 120 },
                    { field: 'm1', title: '01月', width: 60 },
                    { field: 'm2', title: '02月', width: 60 },
                    { field: 'm3', title: '03月', width: 60 },
                    { field: 'm4', title: '04月', width: 60 },
                    { field: 'm5', title: '05月', width: 60 },
                    { field: 'm6', title: '06月', width: 60 },
                    { field: 'm7', title: '07月', width: 60 },
                    { field: 'm8', title: '08月', width: 60 },
                    { field: 'm9', title: '09月', width: 60 },
                    { field: 'm10', title: '10月', width: 60 },
                    { field: 'm11', title: '11月', width: 60 },
                    { field: 'm12', title: '12月', width: 60 },
                    { field: 'mm', title: '全年', width: 60 }

                ]],
                rowStyler: function (index, row) {
                    if (!row.pcode) {
                        return 'background-color:#6293BB;color:#fff;font-weight:bold;';
                    }
                },
                footer: "#ui_hzMonthByZhengYear_dg2_ft"
                //,
                //toolbar: toolbar.length == 0 ? null : toolbar
                //toolbar: [{
                //    text: '导出',
                //    iconCls: 'icon-bug_go',
                //    handler: function () { ui_hzBaseSectionBy_export(); }
                //}, {
                //    text: '删除',
                //    iconCls: 'icon-bug_delete',
                //    handler: function () { ui_hzBaseSectionBy_delete(); }
                //}, {
                //    text: '回复',
                //    iconCls: 'icon-bug_edit',
                //    handler: function () { ui_hzBaseSectionBy_edit(); }
                //}]           
            });
        }

    }

</script>
<div id="ui_hzMonthByZhengYear_layout" class="easyui-layout" data-options="fit:true,border:false">
    <div style="display:none"><iframe id="ui_hzMonthByZhengYear_export_excel" style="display:none"></iframe></div>  
    <div data-options="region:'center',border:false">        
        <div id="ui_hzMonthByZhengYear_layout_toolbar" class="datagrid-toolbar" style="padding: 2px 5px;">

            <input class="easyui-numberspinner" id="ui_hzMonthByZhengYear_search" name="ui_hzMonthByZhengYear_search" data-options="min:2000,max:2030" style="width: 80px;" />
            <select class="easyui-combobox" name="ui_hzMonthByZhengYear_type" id="ui_hzMonthByZhengYear_type" data-options="panelHeight:120,editable:false">
                <option value="all">全部</option>
                <option value="骨灰堂">骨灰堂</option>
                <option value="埋葬地">埋葬地</option>     
                <option value="公墓">公墓</option>
                <option value="塔园">塔园</option>                                        
                <option value="其他">其他</option>
            </select>
            <input class="easyui-combotree" id="ui_hzMonthByZhengYear_areacode" name="ui_hzMonthByZhengYear_areacode"
                                data-options="url: 'ashx/bg_area.ashx?action=getzheng', lines:true,required:true" />
            <img style="cursor: pointer; vertical-align: middle;" onclick="$('#ui_hzMonthByZhengYear_areacode').combotree('clear');"
                        alt="清空" title="清空" src="themes/icons/edit-clear.png" />
            <a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-search" onclick="ui_hzMonthByZhengYear_search()">查询</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-export" onclick="ui_hzMonthByZhengYear_export()" id="ui_hzMonthByZhengYear_btn_export" >导出</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-store" onclick="ui_hzMonthByZhengYear_detail()">内部入葬情况统计</a>
        </div>

        <div id="ui_hzMonthByZhengYear_header" class="datagrid-header" style="text-align: center; font-weight: 600"><span id="ui_hzMonthByZhengYear_spanYear" style="color: blue">全市</span>入葬情况统计表</div>
        <table id="ui_hzMonthByZhengYear_dg" data-options="fit:true,border:false">
        </table>
        <div id="ui_hzMonthByZhengYear_dg_ft" style="height:50px"></div>
    </div>
    <div data-options="region:'east',split:true,border:true,collapsed:true" title="年度入葬统计">
        <div  class="datagrid-toolbar" style="padding: 2px 5px;">            
            <a href="javascript:void(0);" class="easyui-linkbutton" iconcls="icon-export" onclick="ui_hzMonthByZhengYear_export2()" id="ui_hzMonthByZhengYear_btn_export2" >导出</a>
        </div>
        <table id="ui_hzMonthByZhengYear_dg2" data-options="fit:true,border:false">
        </table>
        <div id="ui_hzMonthByZhengYear_dg2_ft" style="height:50px"></div>
    </div>
</div>
